<?php 
namespace App\Infra\User;

use App\Utils\ModelSDK\ModelOperator;
use App\Models\Message;
use App\Models\Reply;

class MessageManage{

	use ModelOperator;

	public function createMessage($data){
		$this->create(Message::class,$data);
	}

	public function createReply($data){
		$this->create(Reply::class,$data);
	}

	public function getMessageAndReply($conditions){
		return $this->findModel(Message::class,Message::query()->with(['replys','weChatDoctorInfo','wechatUser'])->orderBy('created_at','DESC'),$conditions,true);
	}

	public function getDoctor($conditions){
		return $this->findModel(Message::class,Message::query()->with(['weChatDoctorInfo.wechatDoctor']),$conditions,false);
	}

	public function getUser($conditions){
		return $this->findModel(Message::class,Message::query()->with(['wechatUser']),$conditions,false);
	}
}